package com.sheep;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.log4j.PropertyConfigurator;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 16-4-14
 * Time: 下午4:09
 * To change this template use File | Settings | File Templates.
 */
public class AppMain {
    private static final Log log = LogFactory.getLog(AppMain.class);
    protected static AbstractApplicationContext context = null;
    public static void main(String[] args) {
        try {
            PropertyConfigurator.configure(System.getProperty("user.dir") + "/conf/log4j.properties");
            if(context == null) {
                context = new FileSystemXmlApplicationContext("conf/applicationContext.xml");
            }
            log.info("Hive Application Running");
            context.registerShutdownHook();
//            CommonService cs = context.getBean(ImplCommon2Service.class);
//            long startT = System.currentTimeMillis();
//            String tablename = "adsbtest5";
//            cs.createTable();
//            List<String> list = cs.getAllTableRecord(tablename);
//            log.error(list.size()+"----upload to cloud:" + (System.currentTimeMillis() - startT));
//            HiveRunner runner = context.getBean(HiveRunner.class);
//            runner.call();

//            ADSBUtil userUtils = context.getBean(ADSBUtil.class);
//            userUtils.initialize();
//            userUtils.addADSB();
//
//            CommonRepository userRepository = context.getBean(CommonRepository.class);
//            List<ADSBBean> users = userRepository.findAll();
//            System.out.println("Number of users = " + users.size());
//            System.out.println(users);
        } catch (Exception e) {
            log.error(e);
        }
    }
}
